function S = PSWM_ConsensusScore(M)

% S = PSWM_ConsensusScore(M)
%
% Consensus Score for a PSWM.
% M - Matrix.

% Re-normalize just in case...
M = M./(ones(4,1)*sum(M,1));
M(find(M==0)) = 1;

S = 0;
for i=1:size(M,2)
  for j=1:4
    S = S + M(j,i)*log2(M(j,i));
  end
end

S = 2 + S/size(M,2);
